package com.tanhua.tanhua.service.cs;
import io.jsonwebtoken.ExpiredJwtException;
import io.jsonwebtoken.Jwts;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.Map;
@Service
@Slf4j
public class Checktoken {




    public static Boolean checktoken(String token,String secret) {


        try {

            Map<String, Object> body = Jwts.parser()
                    .setSigningKey(secret)
                    .parseClaimsJws(token)
                    .getBody();
//            int i=1/0;

        } catch (ExpiredJwtException e) {
            log.info("token已经过期！ token = " + token);
            return false;
        } catch (Exception e) {
            log.error("token不合法！ token = "+ token, e);
            return false;
        }
        return true;
    }
}
